home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windows 98 Secrets
/
Windows 98 Secrets Gold - Disc 1.iso
/
tools
/
textedit
/
winedit
/
wwwedit.dl_
/
wwwedit.dl
Wrap
Text File
|
1996-10-25
|
14KB
|
340 lines
; This is a common WIL script file for the editor. It is used by both the
; utility menu in the Professional version and also for some internal
; editor functions...like looking up keyword help on a mouse click.
CancelCmd="exit"
goto %param1%
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
:BUTTONMACRO
; we get here via a line like
; Call("WWWEDIT.DLL", "BUTTONMACRO 1") Add a goto label to jump to
; a specific section
; e.g.
; goto butmac%param2%
; :butmac1
; code here
; return
; :butmac2
; code here
; return
Message("Sample Macro","You called user macro number %param2%")
exit
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
:KEYWORDHELP
;First do some initialization and grab the word help is desired for.
;debug(1)
CancelCmd="goto KWHDONE" ; Setup cancel processing - clear variables
HelpWord = wEdGetWord() ; Get Selected word
if HelpWord==""
Message("WinEdit Help Error","Cursor must be on a word to use this function.")
else
; Locate our WEHELP.INI file and determine help file list to process
WEDir = DirHome()
inifile = StrCat(WEDir, "HELP\WEHELP.INI")
if FileExist(inifile)==@FALSE then inifile=FileLocate("WEHELP.INI")
filext = FileExtension(wGetFileName())
If filext == "" Then filext = "NONE" ; section for files w/no extension
helpsec = IniReadPvt("EXTENSIONS", filext, "DEFAULT", inifile)
HFnum = 0
; Get the next help file from the list,
for HFNUM=1 to 1000
ffound=0
wehinfo = StrUpper(IniReadPvt(helpsec, "HF%HFnum%", "NONE", inifile))
If wehinfo == "NONE"
Message("WinEdit Help Error - %helpword%", "No applicable help files found.")
break
endif
if wehinfo == "" then continue ; Empty HFx setting, skip
; Extract and build information from the HFx setting
hfr2=strindex(wehinfo," ",0,@backscan)
HelpFileI=strsub(wehinfo,1,hfr2-1) ; Long File Name Fix
wehfile = StrCat(WEDir, "HELP\",FileRoot(HelpFileI), ".WEH")
if FileExist(wehfile)==@FALSE then wehfile=FileLocate(StrCat(FileRoot(HelpFileI),".WEH"))
wehtype=strsub(wehinfo,hfr2+1,-1)
; Make sure we have a WEH file someplace
If !(FileExist(wehfile))
Message("WEHELP.INI Error", "%wehfile% not found")
break
endif
; Read Keyword data from WEH file
wehdata=IniReadPvt("KEYWORDS",helpword,"",wehfile)
If wehdata == "" Then continue ; No keyword defined, try next file.
;debug(0)
ffound=1
;WEH file located. See if WEH file contains search hints.
helpfile2=IniReadPvt("LOOKUP","Located","",wehfile)
if !FileExist(helpfile2)
HelpFile2=HelpFileI ; then test actual ini setting
if !FileExist(HelpFile2)
ffound=0
while 1
if WinMetrics(-2)==2 ; 32 bit platform
HintName=IniReadPvt("LOOKUP","ALTLONG","",wehfile)
hintreg=IniReadPvt("LOOKUP","REG32","",wehfile)
if hintname!="" then gosub hlpsrch
if ffound==1 then break
HintName=IniReadPvt("LOOKUP","ALTSHORT","",wehfile)
if hintname!="" then gosub hlpsrch
if ffound==1 then break
endif
HintName=IniReadPvt("LOOKUP","ALTSHORT","",wehfile)
hintreg=IniReadPvt("LOOKUP","REG16","",wehfile)
if hintname!="" then gosub hlpsrch
if ffound==1 then break
hintname=strcat(FileRoot(HelpFileI),'.',FileExtension(HelpFileI))
hintreg=""
gosub hlpsrch
break
endwhile ; random searching
if ffound==0
; Give up and ask user....what a concept...
while 1
HelpFile2=HelpFile ; ask user
CancelCmd="goto HELPCAN23"
HelpFile2=AskFileName("Please locate %HelpFile%","","Help Files (*.HLP)|*.HLP|",HelpFile2,1)
CancelCmd="exit"
; Verify we can access help file user entered
if FileExist(HelpFile2)
ffound=1
break
endif
; If cancelled, remove reference to help file from WEHELP.INI
:HELPCAN23
a=AskYesNo(HelpFile2,"Do you wish to remove %HelpFile% from the help file search?")
if a==@YES then IniWritePvt(helpsec,"HF%HFnum%","",inifile)
break
endwhile ;asking user
endif ; asking user
endif ; raw ini setting
IniWritePvt("LOOKUP","Located",helpfile2,wehfile) ; save in weh file for next time
endif ; file not located in weh hint
if ffound==0 then continue
break ; done. break out of next file for loop
next ; next HFx for loop
if ffound==1
switch wehtype
case 1
wehdata=strreplace(wehdata,"~",strcat(num2char(13),num2char(10)))
Message(helpword,wehdata)
break
case 2
WinHelp(HelpFile2,"PARTIALKEY",helpword)
break
case 3
ErrorMode(@OFF)
RunZoom(HelpFile2,helpword)
ErrorMode(@CANCEL)
if LastError()==1902 then Message("WinEdit Help Error","Help for >%helpword%< not available.")
break
case 100
; Put your HelpFileType 100 stuff here
Message("WinEdit User Help - %HelpFile2%","Help for %helpword% goes here")
break
end switch
endif
endif ; from initial check for cusror on word
:KWHDONE
; Drop variables to save memory space
Drop(HelpWord,WEDir,inifile,filext,helpsec,HFnumhintreg,hintdir,hintname,ffound)
Drop(wehinfo,HelpFileI,wehfile,wehtype,wehdata,HelpFile,HelpFile2)
Exit
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
:HLPSRCH
hintdir=""
ErrorMode(@OFF)
if hintreg!="" then hintdir=RegQueryValue(@RegMachine,hintreg)
ErrorMode(@CANCEL)
if hintdir==0 then hintdir=""
helpfile2= strcat(hintdir,hintname)
if !FileExist(helpfile2)
; First of all, completely ignore path to help file specified and
; look in help directory FIRST!
HelpFile=hintname
HelpFile2=strcat(DirHome(),"HELP\%HelpFile%") ;look in HELP dir first
if !FileExist(HelpFile2)
; Remove directory, and let Windows search path
HelpFile2=HelpFile ; try local dir and path
if !FileExist(HelpFile2)
; Check editor home dir just in case path search bypassed it
HelpFile2="%WEDir%%HelpFile%" ; check editor dir
if !FileExist(HelpFile2) then return
endif
endif
endif
ffound=1
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
:REBUILD
; Rebuild Macro Menu
;
; This script writes out WinEdit's Macro Menu script. Each WBT or MAC
; file that is found in the Macros subdirectory becomes a menu item
; on the Macro Menu. You can nest subdirectories of scripts under the
; Macros directory and this script will create a popout submenu for
; that subdirectory.
; You can modify the path variable below to point to a different
; location for storing your WIL scripts, but don't change the save location
; of the menu script, MACRO.MNU. It needs to be saved in WinEdit's
; home directory.
CRLF=strcat(num2char(13),num2char(10))
path = strcat(DirHome(),"Macros")
if !DirExist(path) then DirMake(path)
bufsize = min(16384,FileSize(strcat(DirHome(),"Macro.MNU")) * 2)
menufile = BinaryAlloc(bufsize)
offset = 0
;menufile = FileOpen(strcat(DirHome(),"Macro.MNU"), "WRITE")
offset = offset + BinaryPokeStr(menufile, offset, strcat(';',CRLF))
offset = offset + BinaryPokeStr(menufile, offset, strcat('; WinEdit Script for Macro Menu',CRLF))
offset = offset + BinaryPokeStr(menufile, offset, strcat(';',CRLF))
offset = offset + BinaryPokeStr(menufile, offset, strcat('; WinEdit records macros as WIL scripts. After recording a macro,',CRLF))
offset = offset + BinaryPokeStr(menufile, offset, strcat('; save the resulting script in the WinEdit\Macros directory.',CRLF))
offset = offset + BinaryPokeStr(menufile, offset, strcat(';',CRLF))
offset = offset + BinaryPokeStr(menufile, offset, strcat('; The wRecord() macro function will rebuild this script whenever you save ',CRLF))
offset = offset + BinaryPokeStr(menufile, offset, strcat('; a new macro, with the basename of each file used as the menu item.',CRLF))
offset = offset + BinaryPokeStr(menufile, offset, strcat(';',CRLF))
offset = offset + BinaryPokeStr(menufile, offset, strcat('; Macros stored in subdirectories of the WinEdit\Macros directory will',CRLF))
offset = offset + BinaryPokeStr(menufile, offset, strcat('; be shown as popout menus, with the subdirectory name used as the menu name',CRLF))
offset = offset + BinaryPokeStr(menufile, offset, strcat(';',CRLF))
offset = offset + BinaryPokeStr(menufile, offset, strcat('; Advanced users can examine and modify the Rebuild script, which is contained',CRLF))
offset = offset + BinaryPokeStr(menufile, offset, strcat('; in the WWWEDIT.DLL script file stored in the Windows directory.',CRLF))
offset = offset + BinaryPokeStr(menufile, offset, CRLF)
offset = offset + BinaryPokeStr(menufile, offset, CRLF)
offset = offset + BinaryPokeStr(menufile, offset, strcat('Record \ ^R ; Start or Stop recording a macro',CRLF))
offset = offset + BinaryPokeStr(menufile, offset, strcat(' wRecord()',CRLF))
offset = offset + BinaryPokeStr(menufile, offset, strcat('',CRLF))
offset = offset + BinaryPokeStr(menufile, offset, strcat('Edit Macro Script ; Open a Macro Script file for editing',CRLF))
offset = offset + BinaryPokeStr(menufile, offset, strcat(' types="WIL Files|*.wbt;*.mac;*.mnu|"',CRLF))
offset = offset + BinaryPokeStr(menufile, offset, strcat(' filename = AskFileName("Edit Macro Script", strcat(DirHome(),"Macros"), types, "", 1)',CRLF))
offset = offset + BinaryPokeStr(menufile, offset, strcat(' wFileOpen(filename)',CRLF))
offset = offset + BinaryPokeStr(menufile, offset, strcat(' Drop(filename)',CRLF))
offset = offset + BinaryPokeStr(menufile, offset, CRLF)
if (WinVersion(@MAJOR)) >= 4
offset = offset + BinaryPokeStr(menufile, offset, strcat('Open Macro Menu Folder ; Directly edit the Macro Menu Folder',CRLF))
runstring = strcat(DirHome(),"Macros")
offset = offset + BinaryPokeStr(menufile, offset, strcat(' Run("Start","%runstring%")',CRLF))
offset = offset + BinaryPokeStr(menufile, offset, CRLF)
endif
offset = offset + BinaryPokeStr(menufile, offset, strcat('Rebuild Macro Menu ; Build a menu of scripts in the Macros folder',CRLF))
offset = offset + BinaryPokeStr(menufile, offset, strcat(' call("WWWEDIT.DLL","REBUILD")',CRLF))
offset = offset + BinaryPokeStr(menufile, offset, CRLF)
; process scripts in subdirectories as popout menus, using the
; directory name as the menu item
DirChange(path)
DirList = DirItemize("*.*")
DirCount = ItemCount(DirList,@Tab)
i = 0;
indent = @TRUE
separator = @TRUE
while (i < DirCount)
DirName = ItemExtract(i+1,DirList,@Tab)
DirChange(DirName)
; check to see if there are any script files
FileList = FileItemize("*.WBT|*.MAC")
FileCount = ItemCount(FileList,Tab)
if FileCount
if separator
offset = offset + BinaryPokeStr(menufile,offset, strcat("_%DirName%",CRLF))
else
offset = offset + BinaryPokeStr(menufile,offset, strcat("%DirName%",CRLF))
endif
separator = @FALSE
gosub DoFiles
endif
DirChange(path)
i = i+1
endwhile
Drop(DirList,DirCount,i)
; then do the files in the Macros directory,
; each filename becomes a menu item
indent = @FALSE
separator = @TRUE
DirName = ""
gosub DoFiles
BinaryWrite(menufile,strcat(DirHome(),"Macro.MNU"))
BinaryFree(menufile)
Drop(FileList,FileCount,path,menufile,indent,separator,DirName,offset,bufsize,CRLF)
return
:DoFiles
FileList = FileItemize("*.WBT|*.MAC")
FileCount = ItemCount(FileList,Tab)
index = 0
total = 1
while (index < FileCount)
file = ItemExtract(index+1,FileList,Tab)
name = FileRoot(file)
if (total > 10)
offset = offset + BinaryPokeStr(menufile,offset, strcat("_More Macros",CRLF))
indent = @TRUE
total = 1
endif
if indent
if separator
offset = offset + BinaryPokeStr(menufile,offset, strcat(" _%name%",CRLF))
else
offset = offset + BinaryPokeStr(menufile,offset, strcat(" %name%",CRLF))
endif
total=1
else
if separator
offset = offset + BinaryPokeStr(menufile,offset, strcat("_%name%",CRLF))
else
offset = offset + BinaryPokeStr(menufile,offset, strcat("%name%",CRLF))
endif
endif
separator = @FALSE
if strlen(DirName) > 0
name = strcat(path,"\%DirName%\")
else
name = strcat(path,"\")
endif
fullname = strcat(name,file)
offset = offset + BinaryPokeStr(menufile,offset, strcat(' if FileExist("%fullname%")',CRLF))
offset = offset + BinaryPokeStr(menufile,offset, strcat(' call("%fullname%","")',CRLF))
offset = offset + BinaryPokeStr(menufile,offset, strcat(' endif',CRLF))
offset = offset + BinaryPokeStr(menufile,offset, CRLF)
index = index+1
total = total+1
endwhile
offset = offset + BinaryPokeStr(menufile,offset,CRLF)
Drop(index,file,name,fullname,total)
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Exit ; Put an exit here in case anyone ever drops through to cancel
; Not that we would ever do anything like that ourselves...
:CANCEL
%CancelCmd%